<script>
	$(function() {
		$( "button, input:submit, a", ".demo" ).button();
		$( "a", ".demo" ).click(function() { return true; });
	});
</script>
	<style type="text/css">
		#datos{
			-moz-border-radius: 10px 10px 10px 10px;
			background: none repeat scroll 0 0 #FFFFFF;
			border: 1px solid #99CC00;
			}
	</style>
	
<h1>Descripcion del Itinerario</h1>

</br>
	<div id="datos" style=" float:left; margin-left: 15%; width: 70%;">
	<div style="margin-left: 5%;"><h2><%= @trip.tri_country%> - <%= @trip.tri_city%></h2></div>
		<div style="float:left; margin-left: 5%; margin-top: 2%;">
		<%=image_tag(@itinerary.iti_image_url, :size => "200x200") %>
		
			<div style="margin-left: 5%; float: left; margin-top: 10%; text-align: center;">
				<% if (isOwner(@itinerary.trip_id) and (isAvailable(@itinerary.trip_id))) %>
					<%= link_to "Editar Itinerario", edit_itinerary_path(@itinerary) %>
				<% end-%>
			</div>
		
		</div>
		
		<div style="float:left; margin-left:14%; width: 51%;">
			<p>
				<b>Lugar de Destino: </b>
				<%=h @itinerary.iti_location %>
			</p>

			<p>
			  <b>Fecha Inicio: </b>
			  <%=h @itinerary.iti_start_date.strftime("%d-%m-%Y") %>
			</p>

			<p>
			  <b>Fecha Finalizacion:</b>
			  <%=h @itinerary.iti_end_date.strftime("%d-%m-%Y") %>
			</p>

			<p>
			  <b>Descripcion:</b>
			  <%=h @itinerary.iti_description %>
			</p>
			
			<p>
				<h4>Cantidad de Votos Actuales: <%=h@countVotes.count%></h4>
			</p>
			
				  <% realizoVoto=false %>
				  <% @votes.each do |vota|%>
						<% realizoVoto=true %>
				  <% end -%>
			
			<div style="float: left; margin-left: 5%; width: 70%; text-align: center;">
				<% if (isAvailable(@itinerary.trip_id)) %>	
				  <% if (realizoVoto) %>
					<h5>Ya diste tu voto por este Itinerario!</h5>
				  <% else%>
							<h5>Vota por este Itinerario!</h5>
							<% form_for(@itinerary.vote.new) do |f| %>
								<%= f.error_messages %>
								<%= f.hidden_field(:itinerary_id, :value => @itinerary.id)%>
								<%= f.hidden_field(:user_id, :value => current_user.id) %>
								<%= f.submit "Votar!" %>
							<% end %>
				  <% end-%>
				<% end-%>
			</div>
		</div>
		
	</div>


		<script src="http://maps.google.com/maps/api/js?v=3.1&sensor=false" type="text/javascript"></script>
		<div id="map" style="width:400px; height:400px; margin-left: 5%; margin-top:35%;"></div>



	<div id="datos" style=" float:left; margin-left: 49%; width: 51%; margin-top: -41%; height: 395px;">
		<div style="text-align: center;">
			<h2>Comentarios Realizados (<%=h @comments.count%>):</h2>
		</div>
		<% if @comments.count > 0%>	
			 <% @comments.each do |comentario|%>
				<div style="margin-left: 5%;">
					<td>
							<tr>
								<%=image_tag(@user.picture, :size => "30x30") %>
							</tr>
							<tr>
								<td><b><%=h comentario.user.name + " " + comentario.user.name2 + "  dice:"%></b><br /></td>
								<td><tr>&nbsp</tr><tr>&nbsp</tr><tr>&nbsp</tr><%= comentario.body%></td>
							</tr>
					</td>
					<br />
				</div>
			<% end -%>
		<% else%>
			<div style="text-align: center;">
				<h3>No se ha comentado este destino</h3>
			</div>
		<% end%>
	
		<br />
		<div style="text-align: center;">
			<% if (isAvailable(@itinerary.trip_id)) %>
				<h5>Haz tu Comentario!</h5>
				<% form_for(@itinerary.comment.new) do |f| %>
					<%= f.error_messages %>
					<%= f.hidden_field(:itinerary_id, :value => @itinerary.id)%>
					<%= f.hidden_field(:user_id, :value => current_user.id) %>
					<td><%= f.text_area :body, :rows=>2,:cols=>40 %></td>
					<%= f.submit "Grabar" %>
				<% end %>
			<% end %>
		</div>
</div>
<br />
<% if (isOwner(@itinerary.trip_id) and (isAvailable(@itinerary.trip_id))) %>
<%= link_to "Edit", edit_itinerary_path(@itinerary) %> |
<% end-%>

<div class="demo"><%= link_to "Regresar", :controller => "trips", :action => "show", :id => @itinerary.trip_id %></div>

<input type="hidden" id="latitude" name="latitude" value="<%= @itinerary.iti_latitude %>">
<input type="hidden" id="longitude" name="longitude" value="<%= @itinerary.iti_longitude %>">
<input type="hidden" id="location" name="location" value="<%= @itinerary.iti_location %>">